package com.weijianhuawen.wjblog.common.domain.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.weijianhuawen.wjblog.common.domain.dos.ArticleContentDo;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-10-24 16:36
 */
public interface ArticleContentMapper extends BaseMapper<ArticleContentDo> {
    // 根据文章内容删除文章对应内容
    default int deleteArticleContentByArticleId(Long articleId) {
        return delete(Wrappers.<ArticleContentDo>lambdaQuery()
                .eq(ArticleContentDo::getArticleId, articleId));
    }

    // 根据文章id查询文章内容
    default ArticleContentDo selectByArticleId(Long articleId) {
        return selectOne(Wrappers.<ArticleContentDo>lambdaQuery()
                .eq(ArticleContentDo::getArticleId, articleId));
    }

    // 通过文章id更新
    default int updateByArticleId(ArticleContentDo articleContentDo) {
        return update(articleContentDo, Wrappers.<ArticleContentDo>lambdaQuery()
                .eq(ArticleContentDo::getArticleId, articleContentDo.getArticleId()));
    }
}
